// import { pic1, pic2 } from './base64'
const { Random } = require('mockjs')
var Mock = require('mockjs')
Mock.setup({
  timeout: 1000
})

Mock.mock(RegExp('/api/setting/projects' + '.*'), 'get', function (options) {
  const pic1 = 'https://bkimg.cdn.bcebos.com/pic/3b87e950352ac65c1038eb4e74bba5119313b07e1cfe?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UxNTA=,g_7,xp_5,yp_5/format,f_auto'
  const pic2 = 'https://bkimg.cdn.bcebos.com/pic/a2cc7cd98d1001e9ea71bc84b30e7bec55e797e8?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2U5Mg==,g_7,xp_5,yp_5/format,f_auto'
  return {
    errCode: 0,
    message: '',
    data: Array.from({ length: 10 }).map((item, index) => ({
      id: `HF${Math.ceil(Math.random() * 100)}`,
      name: `项目${Math.ceil(Math.random() * 100)}`,
      childrenNumber: Random.pick([0, 3]),
      remark: 'hf',
      imgUrl: Random.pick([pic1, pic2]),
      createdTime: '20210330154515'
    }))
  }
})

Mock.mock('/api/setting/projects', 'post', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: {}
  }
})

Mock.mock(RegExp('/api/setting/projects' + '.*'), 'delete', function (options) {
  /**
   * 删除的项目ID在url中
  */
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

// Mock.mock(RegExp('/api/setting/projects' + '.*'), 'put', function (options) {
//   return {
//     errCode: 0,
//     message: '操作成功',
//     data: ''
//   }
// })

Mock.mock(RegExp('/api/setting/projects' + '.*'), 'patch', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'get', function (options) {
  const pic1 = 'https://bkimg.cdn.bcebos.com/pic/3b87e950352ac65c1038eb4e74bba5119313b07e1cfe?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UxNTA=,g_7,xp_5,yp_5/format,f_auto'
  const pic2 = 'https://bkimg.cdn.bcebos.com/pic/a2cc7cd98d1001e9ea71bc84b30e7bec55e797e8?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2U5Mg==,g_7,xp_5,yp_5/format,f_auto'
  return {
    errCode: 0,
    message: '',
    data: Array.from({ length: 100 }).map((item, index) => ({
      projectId: Random.pick(['HF1', 'HF2', 'HF3', 'HF4']),
      id: `XX${index}`,
      name: '软件1',
      status: '开发中',
      version: '1.0.1',
      disabled: Random.pick(['0', '1']),
      ip: 'http://172.16.34.213:3000',
      port: '3000',
      baseUserId: Random.pick(['123456', '654321', '']),
      baseUserPsd: '000000',
      remark: '基础账号',
      project: {
        id: `HF${Math.ceil(Math.random() * 100)}`,
        name: `项目${Math.ceil(Math.random() * 100)}`,
        childrenNumber: Random.pick([0, 3]),
        explain: 'hf',
        imgUrl: Random.pick([pic1, pic2]),
        createdTime: '20210330154515'
      }
    }))
  }
})

Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'post', function (options) {
  return {
    errCode: 0,
    message: '操作失败',
    data: {}
  }
})

Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'delete', function (options) {
  /**
   *
  */
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

// Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'put', function (options) {
//   return {
//     errCode: 0,
//     message: '操作成功',
//     data: ''
//   }
// })

Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'patch', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

Mock.mock(RegExp('/api/setting/softwares' + '.*'), 'patch', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

Mock.mock('/api/user/login', 'post', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: {
      id: '00000',
      name: '戴拿'
    }
  }
})

Mock.mock('/api/user/quit', 'post', function (options) {
  return {
    errCode: 0,
    message: '操作成功'
  }
})

Mock.mock('/api/setting/projects/dragged', 'patch', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})

Mock.mock('/api/setting/softwares/dragged', 'patch', function (options) {
  return {
    errCode: 0,
    message: '操作成功',
    data: ''
  }
})
